<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    Array.prototype.mySlice = function (num1, num2) {
        num1 = num1 || 0;
        num2 = num2 || this.length;
        // 如果num1为负数处理
        num1 = num1 < 0 ? num1 + this.length : num1;
        // num2是否传参处理
        num2 = num2 < 0 ? this.length : num2;
        var arr = [];
        for (var i = num1; i < num2; i++) {
            arr.push(this[i])
        }
        return arr
    }
    var arr = [1, 2, 3, 4, 5, 6]
    console.log(arr.mySlice(2));
    console.log(arr.mySlice(2, 4));  


</script>

</html>